var that = this;
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentData:"",
    id:"",
  },
  //取消订单
  cancel(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    app.util.request({
      'url':"entry/wxapp/zhuanjia.gh_quxiao",
      data:{
        id:id
      },
      success:function(res){
        wx.navigateBack({
          complete: (res) => {},
        })
      }
    })
  },
//去支付
gopay(e){
  var that = this
  var back_orser = e.currentTarget.dataset.back_orser
  var money = e.currentTarget.dataset.money
  var key_words = e.currentTarget.dataset.key_words
  var zid = e.currentTarget.dataset.zid
  var j_id = e.currentTarget.dataset.j_id;
  if (money == '0.00') {
    app.util.request({
      'url': 'entry/wxapp/yuyue.msgdh',
      data: {
        orders: back_orser,
        text: '挂号预约'
      },
      success: function (res) {
        console.log(res)

      }
    })
    wx.showToast({
      title: '预约成功！',
      icon: 'none',
      success: function () {
        setTimeout(function () {
          that.setData({
            list:[],
            page:0
          })
          that.getList(that.data.currentData);
        }, 1900)
      }
    })
    return;

  } else {
    app.util.request({
      'url': 'entry/wxapp/yuyue.paywenzhen',
      header: {
        "Content-Type": "application/xml"
      },
      method: "GET",
      data: {
        openid: wx.getStorageSync('openid'),
        z_tw_money: money,
        orders: back_orser,
        key_words: key_words
      },
      success: function (res) {
        console.log(res);
        wx.requestPayment({
          'timeStamp': res.data.timeStamp,
          'nonceStr': res.data.nonceStr, //字符串随机数
          'package': res.data.package,
          'signType': res.data.signType,
          'paySign': res.data.paySign,
          success: function (res) {
            console.log(res)

          },
          fail: function (res) {
            console.log(res)

          },
          'complete': function (res) {
            if (res.errMsg == 'requestPayment:ok') {
              app.util.request({
                'url': 'entry/wxapp/yuyue.msgdh',
                data: {
                  orders: orders,
                  text: '挂号预约'
                },
                success: function (res) {
                  console.log(res)

                }
              })
              wx.showToast({
                title: '预约成功！',
                icon: 'none',
                success: function () {
                  setTimeout(function () {
                    wx.navigateBack({
                      complete: (res) => {},
                    })
                  }, 1900)
                }
              })
              return;
            }
          }
        })
      }
    })
  }
},
  //完成
  finish() { },
  //去退款
  refund(e){
    var id = e.currentTarget.dataset.id;
    app.util.request({
      'url':"entry/wxapp/zhuanjia.gh_refund",
      data:{
        id:id
      },
      success:function(res){
        wx.navigateBack({
          complete: (res) => {},
        })
      }
    })
  },
  //删除
  deleteitem(e){
    var that = this;
    var id = e.currentTarget.dataset.id;
    app.util.request({
      'url':"entry/wxapp/zhuanjia.gh_del",
      data:{
        id:id
      },
      success:function(res){
        wx.navigateBack({
          complete: (res) => {},
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var id = options.id;
    this.setData({
      currentData: options.currentData,
      id:id
    })
    this.getDetail();
  },
  getDetail:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/zhuanjia.gh_detail",
      data:{
        id:that.data.id
      },
      success:function(res){
        that.setData({
          info:res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})